{ Statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=202
  Verdict: Accepted
}
uses
	SysUtils, Math;
 
var
	n, i, j : longint;
	p, a : array[0..10010] of boolean;
 
begin
	reset(input,'input.txt');
	rewrite(output,'output.txt');
	fillchar(a, sizeof(a), 0);
	fillchar(p, sizeof(p), true);
	p[1] := false;
	read(n);
	for i := 2 to n do begin
		j := i * i;
		while j <= n do begin
			p[j] := false;
			inc(j, i);
		end;			
	end;
	a[1] := true;
	a[2] := true;
	a[3] := true;
	for i := 4 to n do
		a[i] := ((not a[i - 1]) and (not p[i - 1])) or ((not a[i - 2]) and (not p[i - 2])) or 
			((not a[i - 3]) and (not p[i - 3]));
	if a[n] then write(1) else write(2);
end.